package cn.com.sparkle.paxos.event;

public abstract class SpeedControlEvent implements Event {
	public final static int SUGGEST_MAX_PACKAGE_SIZE = 1;

	@Override
	public void event(Object... args) {
		int type = (Integer) args[0];
		switch (type) {
		case SUGGEST_MAX_PACKAGE_SIZE:
			suggestMaxPackageSize((Integer) args[1]);
			break;
		default:
			throw new RuntimeException("not supported argument:" + type);
		}
	}

	public final static void doSuggestMaxPackageSizeEvent(
			EventsManager eventsManager, int suggestSize) {
		eventsManager.doEvent(SpeedControlEvent.class,
				SUGGEST_MAX_PACKAGE_SIZE, suggestSize);
	}

	public abstract void suggestMaxPackageSize(int suggestSize);
}
